<template>
  <div>
   <div class="file_list">
      <van-cell  style="display: flex;" >
        <input class="cell_begin" type="text" placeholder="请选择治疗结束时间" @click="show = true"  :value="date"  />
        <el-icon class="begin_icon"><CaretBottom /></el-icon>
      </van-cell>
      <van-calendar :min-date="minDate" :max-date="maxDate" v-model:show="show"  @confirm="onConfirm" />
      </div>
      <!-- 子传父 -->
  </div>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router'
import { h, ref, shallowRef } from 'vue'
// 引入pinia仓库
// import { useDataStore } from '../stores/userStore';

  const date = ref('');
    const show = ref(false);
    const  minDate= new Date(2024, 1, 1)
const  maxDate= new Date(2025, 12,31)
// const dataStore = useDataStore();
const time1=ref('')

const storeData=()=>{
  // dataStore.setStoredData(time1.value)
}
    const formatDate = (date) => {
      return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`;
    };
    const onConfirm = (value) => {
      show.value = false;
      date.value = formatDate(value);

      time1.value = formatDate(value);
      storeData()
      localStorage.setItem('time2', date.value)
    };



</script>

<style scoped lang="scss">
.cell_begin{
  width: 100%;
  margin: 7.5px;
  margin-left: 12.5px;
  padding-bottom: 7.5px;
  border: none;
  font-size: 12px;
  border-bottom: solid 0.5px #ccc;
}

.begin_icon{
  position: absolute;
  top: 7.5px;
  right: 32.5px;
}



</style>
